package com.le.tester.book.effectivejava3rdchinese.articlesixteen;

/**
 * createTime：2022/8/4 10:05
 * description：尽量的使用方法而不是访问公共属性
 */
public final class Time {

    //两个私有
    private static final int HOURS_PER_DAR = 24;
    private static final int MINUTES_PER_HOUR = 60;

    //两个共有
    public final int hour;
    public final int minutes;

    public Time(int hour, int minutes) {
        if (hour < 0 || hour >= HOURS_PER_DAR) {
            throw new IllegalArgumentException("Hour is " + hour);
        }

        if (minutes < 0 || minutes >= MINUTES_PER_HOUR) {
            throw new IllegalArgumentException("minutes is " + minutes);
        }
        this.hour = hour;
        this.minutes = minutes;
    }
}
